package com.mall;

import java.util.Date;
import java.util.Set;

public abstract class AbstractDiscount {
	
	 Date begin;
	 Date end;
	 Date now;
	 boolean isUsed = false;;

	
	public Date getBegin() {
		return begin;
	}
	public void setBegin(Date begin) {
		this.begin = begin;
	}
	public Date getEnd() {
		return end;
	}
	public void setEnd(Date end) {
		this.end = end;
	}
	public boolean isUsed() {
		return isUsed;
	}
	public void setUsed(boolean isUsed) {
		this.isUsed = isUsed;
	}
	
	public Date getNow() {
		return now;
	}
	public void setNow(Date now) {
		this.now = now;
	}
	public boolean isAvalible(){

        boolean isBegin, isEnd;
        if (begin == null) {
        	isBegin = true;
        } else {
        	isBegin = now.compareTo(begin) >= 0 ? true : false;
        }
        if (end == null) {
            isEnd = true;
        } else {
            isEnd = now.compareTo(end) <= 0 ? true : false;
        }
        return isBegin && isEnd;
	}
	
}
